﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">供应商编号</label>
                    <div class="layui-input-block">
                        <input type="text" id="vendorNo" placeholder="请输入" class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">供应商名称</label>
                    <div class="layui-input-block">
                        <input type="text" id="vendorName" placeholder="请输入" class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">负责人电话</label>
                    <div class="layui-input-block">
                        <input type="text" id="vendorPhone" placeholder="请输入" class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">所属市场</label>
                    <div class="layui-input-block">
                        <select id="marketName" lay-filter="testSelect1">
                            <option value="">请选择</option>
                            <option value="华南市场部">华南市场部</option>
                            <option value="华北市场部">华北市场部</option>
                            <option value="海外市场部">海外市场部</option>
                        </select>
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">服务人员</label>
                    <div class="layui-input-block">
                        <select id="salesmanName" lay-filter="testSelect">
                            <option value="">请选择</option>
                            <option value="张三">张三</option>
                            <option value="李思">李思</option>
                            <option value="王五">王五</option>
                        </select>
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">归集档案</label>
                    <div class="layui-input-block">
                        <input type="text" id="vmnemonic" placeholder="请输入" class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">使用状态</label>
                    <div class="layui-input-block">
                        <select id="vstatus" lay-filter="testSelect1">
                            <option value="">全部</option>
                            <option value="启用">启用</option>
                            <option value="禁用">禁用</option>
                        </select>
                    </div>
                </div>


                <button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl" onclick="location.href='/Procurement/AddVendor'">增加</button>
                <button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl">导入导出</button>

            </div>

        </div>

        <table class="layui-table">
            <thead>
                <tr>
                    <td>供应商编号</td>
                    <td>供应商名称</td>
                    <td>供应商类型</td>
                    <td>负责人电话</td>
                    <td>所属市场</td>
                    <td>录入单位</td>
                    <td>使用单位</td>
                    <td>服务人员</td>
                    <td>使用状态</td>
                    <td>修改人</td>
                    <td>最后修改时间</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody></tbody>
        </table>

        <div id="demo-laypage-all"></div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
    <script>
        layui.use(function () {
            var form = layui.form
            var laypage = layui.laypage;
            var pageIndex = 1;
            var pageSize = 5;



            var $ = layui.$;
            var layer = layui.layer;
            var util = layui.util;

            Show();


            //待配提示列表
            function Show() {

                var vendorName = $("#vendorName").val()
                var vendorPhone = $("#vendorPhone").val()
                var marketName = $("#marketName").val()
                var salesmanName = $("#salesmanName").val()
                var vmnemonic = $("#vmnemonic").val()
                var vstatus = $("#vstatus").val()
                var vendorNo = $("#vendorNo").val()
                $.post({
                    url: 'http://localhost:5269/api/Vendor/SearchVendor',
                    data: JSON.stringify({ vendorName: vendorName, vendorPhone: vendorPhone, marketName: marketName, salesmanName: salesmanName, vmnemonic: vmnemonic, vstatus: vstatus, vendorNo: vendorNo, pageIndex: pageIndex, pageSize: pageSize }),
                    async: false,
                    dataType: "json",
                    contentType: "application/json",
                    success: res => {
                        var count = "";

                        $.each(res.data, function () {

                            if (this.updatedOwnerId==null)
                            {
                                this.updatedOwnerId = "";
                            }
                            if (this.updatedTime == null) {
                                this.updatedTime = "";
                            }
                            else
                            {
                                this.updatedTime = moment(this.updatedTime).format("YYYY-MM-DD HH:mm:ss")
                            }


                            count += `
                                                    <tr>
                                                                        <td>${this.vendorNo}</td>
                                                                        <td>${this.vendorName}</td>
                                                                <td>${this.vendorTypeName}</td>
                                                                <td>${this.vendorPhone}</td>
                                                                <td>${this.marketName}</td>
                                                                         <td>宏光养羊</td>
                                                                                        <td>宏光养羊</td>
                                                                <td>${this.salesmanName}</td>

                                                                <td>${this.vstatus}</td>
                                                                <td>${this.updatedOwnerId}</td>
                                                                        <td>${this.updatedTime}</td>
                                                        <td>
                                                          <a onclick="ChaKan()" class="btn btn-link">查看</a>
                                                          <a onclick="funDel()" class="btn btn-link">删除</a>
                                                        </td>
                                                    </tr>
                                                    `
                        })

                        //pagedCount = res.pagedCount;
                        //pcount = res.totalCount;
                        $("tbody").html(count)
                        // console.log(res.data)

                        //var page = Math.ceil(res.totalCount / 5);  //总页数
                        console.log(996, pageSize, pageIndex, res);
                        // 完整显示
                        laypage.render({
                            elem: 'demo-laypage-all', // 元素 id
                            curr: pageIndex,//当前页
                            pages: res.pagedCount,    //总页数
                            limit: pageSize,//每页几条
                            limits: [5, 10, 15],
                            count: res.totalCount, // 数据总数
                            layout: ['count', 'prev', 'page', 'first', 'last', 'next', 'limit', 'skip'], // 功能布局
                            jump: function (obj, first) {
                                if (!first) {
                                    console.log(888, obj);
                                    console.log(obj.curr); // 得到当前页，以便向服务端请求对应页的数据。
                                    console.log(obj.limit); // 得到每页显示的条数
                                    pageIndex = obj.curr;
                                    pageSize = obj.limit;
                                    Show();
                                }
                            }
                        });
                    }
                })


            }

        });
    </script>

</body>

</html>




